|
|
|
| Table 10.1. continued | | Control | Property | Setting | | VB.Label | Name | Label1 | | BorderStyle | 1 'Fixed Single | | Height | 315 | | Left | 120 | | Top | 180 | | Width | 1575 |
|
|
|
|
|
|
After laying out the form, you need to add the code. Enter Listing 10.1 in the general declarations section of the form. This code declares all the form-level variables you use in the project. |
|
|
|
|
|
|
|
|
Listing 10.1. Coding the form-level variables. |
|
|
|
|
|
|
|
|
Option Explicit
'
' form-level vars
'
Dim strDBName As String
Dim strRSName As String
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset |
|
|
|
|
|
|
|
|
Listing 10.2 shows the code that opens the database and then opens a Dynaset for your use. Add this code to the Form_Load event. |
|
|
|
|
|
|
|
|
Listing 10.2. Opening the database and a Dynaset. |
|
|
|
|
|
|
|
|
Private Sub Form_Load()
'
' open db and rs objects
'
strDBName = App.Path & "\..\..\data\books5.mdb"
strRSName = "Authors"
'
Set ws = DBEngine.CreateWorkspace("dbTemp", "admin", "")
Set db = ws.OpenDatabase(strDBName)
Set rs = db.OpenRecordset(strRSName, dbOpenTable)
'
End Sub |
|
|
|
|
|